package com.xone.xapp;

import java.util.ArrayList;
import java.util.List;

import org.apache.http.NameValuePair;
import org.json.JSONObject;

import android.content.Context;
import android.os.Bundle;

import com.xone.refresh.library.PullToRefreshListView;

public class SubscribeListUserActivity extends BasicListActivity<SubscribeListUserHolder> {
	
	protected PullToRefreshListView listView;
	@Override
	public int getContentView() {
		return R.layout.subscribe_list_user;
	}
	@Override
	public String getHeaderTitle() {
		return "用户订阅列表";
	}
	/**
	 * 列表视图
	 */
	@Override
	public PullToRefreshListView getListView() {
		return listView;
	}
	/**
	 * 列表适配器
	 */
	@Override
	public BasicListAdapter<SubscribeListUserHolder> getListAdapter(Context context,
			List<JSONObject> result) {
		return new SubscribeUserAdapter(context, result);
	}
	/**
	 * 列表的请求地址
	 */
	@Override
	public String getRequestURL() {
		return "/subscribe/itemsJson.html";
	}
	/**
	 * 列表的请求参数
	 */
	@Override
	public List<NameValuePair> getRequestParams() {
		return new ArrayList<NameValuePair>();
	}
	/**
	 * 返回的请求中的json根列表名称
	 */
	@Override
	public String getJsonRootName() {
		return "list";
	}
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		if (!ContextUtils.isOnline(this)) {
			return;
		}
		listView = (PullToRefreshListView) findViewById(R.id.subscribe_list_user);
	}
	
	@SuppressWarnings("unchecked")
	protected void onResume() {
		super.onResume();
		showProgress();
		new InitDataTask(this, listView).execute(getRequestParams());
	}

}
